package me.kuye.jkuye.config;

import java.util.ArrayList;
import java.util.List;

import me.kuye.jkuye.aop.Interceptor;
import me.kuye.jkuye.aop.InterceptorBuilder;

/**
 * @author xianyijun
 *
 */
public class Interceptors {
	private final List<Interceptor> globalActionInterceptor = new ArrayList<Interceptor>();

	/*
	 * 将List转化为数组
	 * 
	 */
	public Interceptor[] getGlobalActionInterceptor() {
		return globalActionInterceptor.toArray(new Interceptor[globalActionInterceptor.size()]);
	}

	public Interceptors add(Interceptor globalActionInterceptor) {
		if (globalActionInterceptor != null) {
			this.globalActionInterceptor.add(globalActionInterceptor);
		}
		return this;
	}

	public void addGloablServiceInterceptor(Interceptor globalServiceInterceptor) {
		if (globalServiceInterceptor != null) {
			InterceptorBuilder.addGlobalServiceInterceptor(globalServiceInterceptor);
		}
	}
}
